# Contributor: Tyler A <tylera@privatedemail.net>
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=ndisc6
pkgver=1.0.4
pkgrel=2
pkgdesc="ndisc6 gathers a few diagnostic tools for IPv6 networks including"
url="https://www.remlab.net/ndisc6"
arch="all"
license="GPL-2.0-or-later"
makedepends="linux-headers perl"
depends="sed" # merge-hook uses regex not supported by bb sed
subpackages="$pkgname-doc $pkgname-openrc $pkgname-dnssort::noarch"
source="https://www.remlab.net/files/ndisc6/ndisc6-$pkgver.tar.bz2
	remove-undef-gnu-source.patch
	rdnssd.initd
	rdnssd.resolvconf
	"

build() {
	./configure \
		--build=$BUILD \
		--host=$CHOST \
		--prefix=/usr \
		--localstatedir=/var \
		--sysconfdir=/etc \
		--disable-suid-install
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	install -D -m755 "$srcdir"/rdnssd.initd "$pkgdir"/etc/init.d/rdnssd
	install -D -m755 "$srcdir"/rdnssd.resolvconf \
		"$pkgdir"/etc/rdnssd/resolvconf
}

dnssort() {
	pkgdesc="ndisc6 dnssort (perl)"
	install_if="$pkgname perl"
	depends=perl
	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/dnssort "$subpkgdir"/usr/bin/
}

sha512sums="6f6cd939fb7079518db5c1bcd11353c722237d7735d229f9fd20d03e9f16b1ddf07c7c78c91364886148f2a82d6805eafe7e27da6b4e7c99b111603ec5fab842  ndisc6-1.0.4.tar.bz2
d70c74f965308afbfc266071ec0d073d59cfd42f250e27c8f4f3e1c7b849a6bb9226407e74af30366d348e4213c7497791e8f2edc7b903703e611c036c250644  remove-undef-gnu-source.patch
5475dbe63b2855f6f5fdb0663dd235a4261db44f8f639b4b13712b62f9ca2adf9de6e899e72eee238a284d40d11f9fdd4778e11cdec739ee3abbffc85ac36d21  rdnssd.initd
7b23eafa78bd88d43d0910dbb6cb8d248c00425edb0826571c4d4f9129de33f07093dba4a42f05a549ef1bb9a0fd301716a30bf95ceea18d445e291f0169a444  rdnssd.resolvconf"
